<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/11/6
  Time: 10:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="js/jquery-1.8.2.js"></script>
</head>
<script>
    $(function () {
        var cname='${cb.cname}';
        if(cname!=null&&cname!=""){
            $("#aa").hide();
        }
    })
</script>
<body>
    <center>
        <div style="float: right">
            ${cb.cname}<a id="aa" href="#" onclick="checkcar()">登录</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="toGetShopCarInfo.do">查看购物车</a>
        </div>
        <div style="width: 1000px">
            <c:forEach var="g" items="${list}">
                <a href="toGetGoodsInfo.do?gid=${g.gid}">
                    <dl style="float: left;margin: 20px">
                        <dt><img src="${g.plist.size()==0?"":g.plist.get(0).purl}" height="100px" width="150px"/></dt>
                        <dd>${g.gname}&nbsp;&nbsp;&nbsp;<a style="color: red;font-size: 30px">￥${g.gprice}</a></dd>
                    </dl>
                </a>
            </c:forEach>
        </div>
    </center>
</body>
<script>
    function checkcar() {
        /**
         * 使用ajax去判断用户有没有登录，登录了，直接把表单提交过去，没有登录，还需要去登录
         */
        $.post(
            "getLoginInfo.do?m="+Math.random(),
            {},
            function (data) {
                if(data=='no'){
                    var flag=null;
                    flag = window.open("login.jsp","","height=400px,width=600px");
                    if(flag!=null){
                        location.href="getGoodsWebList.do?m="+Math.random();
                    }
                }
            }
        );
    }
</script>
</html>
